import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Avatar extends StatelessWidget {
  final String avatar;
  final double? radius;

  const Avatar({super.key, required this.avatar, this.radius});

  @override
  Widget build(BuildContext context) {
    return CircleAvatar(
      radius: this.radius,
      backgroundImage: (avatar.isNotEmpty && avatar != "default" ? NetworkImage(avatar) : const AssetImage("assets/logo/logo.png")),
      onBackgroundImageError: (_, _) {
        debugPrint("头像加载失败${avatar}");
      },
    );
  }
}
